package com.situ.ssm.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;

import com.situ.ssm.dao.IStudentDao;
import com.situ.ssm.entity.Student;
import com.situ.ssm.util.MyBatisUtil;

import sun.print.resources.serviceui;

public class StudentDaoImpl implements IStudentDao{
	private SqlSession sqlSession;
	
	public StudentDaoImpl() {
		sqlSession = MyBatisUtil.getSqlSession();
	}
	
	@Override
	public List<Student> selectAll() {
		List<Student> list = sqlSession.selectList("student.selectAll");
		return list;
	}

	@Override
	public List<Student> selectByPage(int offset, Integer limit) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("offset", offset);
		map.put("limit", limit);
		List<Student> list = sqlSession.selectList("student.selectByPage", map);
		return list;
	}

	@Override
	public int selectTotalCount() {
		int count = sqlSession.selectOne("student.selectTotalCount");
		return count;
	}

}
